package com.example.demo.service.impl;

import com.example.demo.entity.RouteDetail;
import com.example.demo.entity.RoutePlan;
import com.example.demo.mapper.RouteDetailMapper;
import com.example.demo.mapper.RoutePlanMapper;
import com.example.demo.service.RouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;

@Service
public class RouteServiceImpl implements RouteService {

    private final RoutePlanMapper routePlanMapper;
    private final RouteDetailMapper routeDetailMapper;

    @Autowired
    public RouteServiceImpl(RoutePlanMapper routePlanMapper,RouteDetailMapper routeDetailMapper) {
        this.routePlanMapper = routePlanMapper;
        this.routeDetailMapper = routeDetailMapper;
    }

    @Override
    public Map<String, Object> getRouteDetail(Long routeId) {
        RoutePlan plan = routePlanMapper.selectById(routeId);
        List<RouteDetail> details = routeDetailMapper.selectByRouteId(routeId);

        Map<String, Object> result = new HashMap<>();
        result.put("imageUrl", plan.getImageUrl());
        result.put("routes", details);
        return result;
    }
}
